/** 
 * ---------------------------------------------------------------------------------------------------------------
 * @Copyright	Quadrangle Systems Inc.
 * @Title		ByteResponseHangler.java   
 * @author 		Peak Zhang
 * @date 		2014-07-11
 * @Description: 
 *				Process byte from http response to string
 * ---------------------------------------------------------------------------------------------------------------
 */ 
package com.qs.education.bean.http;

import java.nio.charset.Charset;

import org.apache.http.Consts;

public class StringResponseHandler implements ResponseHandler {

	public Object handle(Object responseObj) {
		byte[] bObj = (byte[])responseObj;
		return new String(bObj, Consts.UTF_8);
	}

	public boolean accept(Object responseObj) {
		if(responseObj instanceof byte[]){
			return true;
		}
		return false;
	}
	
	public Object handle(Object responseObj,Charset charset){
		byte[] bObj = (byte[])responseObj;
		return new String(bObj, charset);
	}
}
